A good answer might be:

No—this is not allowed and the dot notation does not even give you a way to ask for it.

Method Definition

Now that we have a test program, we can add methods to the class one-by-one, testing each method as it is added. Recall the three methods from the requirements:

Remember the syntax for method definition:

returnType methodName ( parameterList )
{
  statementList
}

The first line in the above is called the header of a method definition. It does not have to be all on one line. The returnType is the data type that the method returns, so it will be one of the primitive data types, or a class. The methodName is an identifier thought of by the programmer; it could be any identifier except for reserved words or identifiers already in use. The parameterList is a list of parameters and their data types. If there are no parameters, the parameter list is omitted, (but not the two parentheses.)

Here is the class definition again:

class CheckingAccount
{
  // instance variables
  String accountNumber;
  String accountHolder;
  int    balance;

  //constructors
  . . . .

  // methods
}

Let us work on a method that will return the current balance. When it is called, it will not alter any data in a checking account object, but merely return the current balance.

QUESTION 10:

Write the first line (the header) of the definition for this method. The method will not use any parameters. You will have to think of a name for the method.